<template>
  <bui-page-layout ref="pageLayout" :is-z-paging="true">
    <z-paging :auto-show-back-to-top="true" empty-view-text="暂无合伙人收益明细" back-to-top-bottom="220rpx" ref="zpaging" safe-area-inset-bottom v-model="dataList" :show-loading-more-when-reload="true" :show-loading-more-no-more-view="true" :auto-clean-list-when-reload="true" @query="getList" :fixed="false" :empty-view-fixed="false">
      <view class="financial-list" v-for="(item,rIndex) in dataList" :key="rIndex">
        <view class="financial-collapse">
          <view class="financial-item">
            <view class="info">
              <view class="name"><text class="n">{{ item.name }}</text></view>
              <view class="time"><text class="n">{{ item.createTime }}</text></view>
            </view>
            <view class="amount">
              <text class="p" :class="{sub:item?.amount?.length < 0,add:item?.amount?.length > 0}">{{(item?.amount?.length > 0?'+':'-')}}{{ item.amount }}</text>
            </view>
          </view>
        </view>
      </view>
    </z-paging>
  </bui-page-layout>
</template>
<script setup>
import { getCurrentInstance, ref, reactive, onMounted, computed } from "vue";
var dataList = ref([
  {
    unpack: true,
    list: [],
  },
]);
var zpaging = ref(null);
const getList = (pageNum, pageSize) => {
  var options = {
    limit: pageSize,
    // month: 11,
    page: pageNum,
  };
  uni.$request
    .service({
      url: "/m/bonus/record",
      method: "POST",
      data: options,
      isLoading: true,
    })
    .then((res) => {
      zpaging.value.completeByTotal(res.list || [], res.total);
    })
    .catch((error) => {
      uni.$u.toast(error.message);
    });
};
const onCollapse = (index) => {
  dataList.value[index].unpack = !dataList.value[index].unpack;
};
</script>
<style lang="scss">
page {
  background-color: #f6f6f8;
}
.friend-info {
  padding: 20rpx 30rpx;
  .t {
    font-size: 28rpx;
    color: #9eb0c5;
  }
}
.financial-list {
  .financial-hd {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20rpx 34rpx 20rpx 40rpx;
    .time {
      display: flex;
      align-items: center;
      .text {
        font-size: 30rpx;
        color: #232f3f;
      }
      .arrow {
        margin-left: 5rpx;
        width: 32rpx;
        height: 32rpx;
        transition: transform 0.3s;
      }
      .arrow.rotate {
        transform: rotate(180deg);
      }
    }
    .amount {
      font-size: 28rpx;
      color: #9eb0c5;
    }
  }
  .financial-item {
    display: flex;
    align-items: center;
    position: relative;
    padding: 14rpx 20rpx;
    background-color: #fff;
    &::after {
      content: "";
      display: block;
      position: absolute;
      left: 20rpx;
      right: 20rpx;
      height: 2rpx;
      background-color: #f3f3f3;
      top: 0;
    }
    .info {
      flex: 1;
      padding-left: 20rpx;
      .name {
        padding-top: 10rpx;
        .n {
          font-size: 28rpx;
          color: #232f3f;
          position: relative;
        }
      }
      .time {
        .n {
          font-size: 24rpx;
          color: #9eb0c5;
        }
      }
      .vip-icon {
        padding-top: 10rpx;
        .icon {
          width: 140rpx;
          height: 40rpx;
        }
      }
    }
    .amount {
      display: flex;
      flex-direction: column;
      margin-right: 14rpx;
      .p {
        font-size: 32rpx;
      }
      .p.add {
        color: #05c160;
      }
      .p.sub {
        color: #fe9900;
      }
      .t {
        font-size: 24rpx;
        color: #9eb0c5;
        text-align: right;
      }
      .status {
        font-size: 24rpx;
        text-align: right;
        padding: 6rpx 0 0 0;
      }
      .status.success {
        color: #05c160;
      }
      .status.fail {
        color: #fc4d42;
      }
      .status.under_review {
        color: #fe9900;
      }
    }
  }
  .financial-item:first-child {
    &::after {
      display: none;
    }
  }
  .financial-collapse {
    transition: height 400ms ease-in-out 0ms;
    transform-origin: 50% 50% 0px;
    height: 0px;
    overflow: hidden;
    .nodata {
      display: flex;
      height: 100rpx;
      justify-content: center;
      align-items: center;
      .t {
        font-size: 24rpx;
        color: #666;
      }
    }
  }
  .financial-collapse.show {
    height: 128px;
  }
}
</style>
